package de.lot.model;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * A trait containig specifications on what students
 * have to do to fail / meet / exceed expectations.
 *
 * @see LearningOutcome
 *
 * @author Stefan Kohler <kohler.stefan@gmail.com>
 */
@Entity
@Table(name = "TRAIT")
public class Trait implements Serializable {

    private Long id;
    private Integer number;
    private String name;
    private String failsExpectations;
    private String meetsExpectations;
    private String exceedsExpectations;
    private LearningOutcome learningOutcome;

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @NotNull
    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    @Length(max = 50)
    @NotNull
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Length(max = 400)
    @NotNull
    public String getFailsExpectations() {
        return failsExpectations;
    }

    public void setFailsExpectations(String failsExpectations) {
        this.failsExpectations = failsExpectations;
    }

    @Length(max = 400)
    @NotNull
    public String getMeetsExpectations() {
        return meetsExpectations;
    }

    public void setMeetsExpectations(String meetsExpectations) {
        this.meetsExpectations = meetsExpectations;
    }

    @Length(max = 400)
    @NotNull
    public String getExceedsExpectations() {
        return exceedsExpectations;
    }

    public void setExceedsExpectations(String exceedsExpectations) {
        this.exceedsExpectations = exceedsExpectations;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "LEARNINGOUTCOME_ID", nullable = false)
    @NotNull
    public LearningOutcome getLearningOutcome() {
        return learningOutcome;
    }

    public void setLearningOutcome(LearningOutcome learningOutcome) {
        this.learningOutcome = learningOutcome;
    }

    @Transient
    public String getTraitLearningOutcomeNumber() {
        return learningOutcome.getNumber() + "." + number;
    }
}
